<?php

namespace app\common\model;

use think\Model;

class Collection extends Model
{
    // 表名,不含前缀
    protected $name = 'collection';
    // 自动写入时间戳字段
    protected $autoWriteTimestamp = true;
    // 定义时间戳字段名
    protected $createTime = 'createtime';
    protected $updateTime = 'updatetime';

    protected $type = [
        'createtime' => 'datetime:Y-m-d H:i:s',
        'updatetime' => 'datetime:Y-m-d H:i:s',
    ];

    /**
     * @var null|static 实例对象
     */
    protected static $instance = null;

    /**
     * 获取示例
     * @param array $options 实例配置
     * @return static
     */
    public static function instance($options = [])
    {
        if (is_null(self::$instance)) self::$instance = new self($options);

        return self::$instance;
    }

    public function innerCollectionJoinContentHasMany()
    {
        return $this->hasMany(CollectionJoinContent::class, 'collection_id', 'id')
            ->with(['innerContentHasOne']);
    }
}